import {createSlice} from '@reduxjs/toolkit'

const initialState = {
  user:{
    userId:'',
    avator:'',
    username:'',
    token:''
  }
}

export const userSlice = createSlice({
  name: 'userSlice',
  initialState,
  reducers: {
    // 同步 - 类似 mutation
    loginMutation: (state, action) => {
      // console.log('接收到修改数据：', action)
      state.user = action.payload
    }
  }
})

export const { loginMutation } = userSlice.actions

export default userSlice.reducer
